package com.dinkshow.dinkshow.user.repoistory;

import com.dinkshow.dinkshow.user.model.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 *功能描述:user 持久层实现
 * @author yuwc
 * @param  * @param null 
 * @return 
 *备注       
 */
@Service("userRepository")
public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor<User> {
    /**
     * 符合JPA命名规则的方法定义  不错·需要多了解
     * @param name
     * @return
     */
    User findFirstByName(String name);


    @Query(value = "from User where position =?1")
    List<User> selectByCustomSqlTest1(String position);

    @Query(value = "select * from wm_user where position = ?1", nativeQuery = true)
    List<User> selectByCustomSqlTest2(String position);

    Page<User> findByNickName(String nickName, Pageable pageable);



}
